package com.wyth.lottery.utils;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;

import com.wyth.lottery.R;


/**
 * Created by Administrator on 2017/9/6.
 */

public class BitmapT {

    public static android.graphics.Bitmap bitmaptest1(Context context) {

        String itemName ="";
        Bitmap mBitmap;
        Rect mSrcRect, mDestRect;
        int w = 631;
        int h = 786;

        //Bitmap qr = BarcodeUtils.creatBarcode(BaseApplication.getContext(), "16887498665498", w / 3, h / 4, true);
        android.graphics.Bitmap mbmpTest = android.graphics.Bitmap.createBitmap(w, h, android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(mbmpTest);
        canvas.drawColor(Color.WHITE);

        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setAntiAlias(true);
        //左对齐
        //paint.setTextAlign(Paint.Align.CENTER);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setTextSize(25);
        paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL));//字体
        canvas.drawText("双色球",245,145, paint);//品名
        canvas.drawText("投注方式: 单式投注 期号：2017095",40,203, paint);//品名
        canvas.drawText("销售时间： 2017-09-23 15:00:00",40,239, paint);//品名
        canvas.drawText("注数：5 面额：10",40,275, paint);//品名
        canvas.drawText("A:01 03 04 05 06 07+13 1倍",40,311, paint);//品名
        canvas.drawText("B:02 03 04 17 06 07+14 1倍",40,347, paint);//品名
        canvas.drawText("C:03 03 24 05 06 07+15 1倍",40,383, paint);//品名
        canvas.drawText("D:04 03 04 33 07 07+13 1倍",40,419, paint);//品名
        canvas.drawText("E:05 03 04 05 06 07+07 1倍",40,455, paint);//品名

        canvas.drawText("站编号： 00000000",40,548, paint);//品名
        canvas.drawText("流水号： 000006",40,578, paint);//品名
        canvas.drawText("开奖： 2017-09-23",40,608, paint);//品名
        canvas.drawText("站地址： 金角大厦",40,638, paint);//品名
//        canvas.drawText("双色球",canvas.getWidth()/18,canvas.getHeight()*1/12, paint);//品名
//        canvas.drawText("双色球",canvas.getWidth()/20,canvas.getHeight()/6, paint);//品名
//        canvas.drawText("投注方式：单式投注期号：2017095",canvas.getWidth()/25,canvas.getHeight()/4, paint);//品名
//        canvas.drawText("销售时间： 2017-09-23 15:00:00",canvas.getWidth()/28,canvas.getHeight()/3, paint);//品名
//        canvas.drawText("注数：5 面额：1234567",20,canvas.getHeight()*5/12, paint);//品名
//        canvas.drawText("A:01 03 04 05 06 07+22 1倍",canvas.getWidth()/10,canvas.getHeight()/2, paint);//品名
//        canvas.drawText("B:02 03 04 05 06 07+22 1倍",canvas.getWidth()/9,canvas.getHeight()*7/12, paint);//品名
//        canvas.drawText("C:02 03 04 05 06 07+22 1倍",canvas.getWidth()/8,canvas.getHeight()*2/3, paint);//品名
//        canvas.drawText("D:02 03 04 05 06 07+22 1倍",canvas.getWidth()/7,canvas.getHeight()*3/4, paint);//品名
//        canvas.drawText("E:02 03 04 05 06 07+22 1倍",canvas.getWidth()/6,canvas.getHeight()*5/6, paint);//品名
//        canvas.drawText("站编号： 00000000",canvas.getWidth()/3,548, paint);//品名
//        canvas.drawText("流水号： 000006",canvas.getWidth()/3,578, paint);//品名
//        canvas.drawText("开奖： 2017-09-23",canvas.getWidth()/3,608, paint);//品名
//        canvas.drawText("站地址： 金角大厦",canvas.getWidth()/3,638, paint);//品名

//
//        paint.setStyle(Paint.Style.FILL);//充满
//        paint.setColor(Color.BLACK);
//        paint.setAntiAlias(false);// 设置画笔的锯齿效果
//        canvas.drawText("画圆角矩形:",250,500, paint);


      /*  RectF oval3 = new RectF(80, 400, 300, 400);// 设置个新的长方形
        canvas.drawRoundRect(oval3, 20, 15, paint);//第二个参数是x半径，第三个参数是y半径*/
        Resources resources = context.getResources();
      android.graphics.Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.zj);
//        mSrcRect = new Rect(0, 0, 250,250);
//        mDestRect = new Rect(0, 0, 250, 250);
//        canvas.drawBitmap(bitmap,mSrcRect,mDestRect,paint);
        canvas.drawBitmap(bitmap, 300,528, paint);
        return mbmpTest;
    }
}
